class Solution {
public:
    int getLeft(vector<int>& nums,int target){
        int l = 0;
        int r = nums.size();
        while(l < r){
            int mid = l + (r - l) / 2;
            if(nums[mid] >= target){
                r = mid;
            }else{
                l = mid + 1;
            }
        }
        return r;
    }
    int getRight(vector<int>& nums,int target){
        int l = 0;
        int r = nums.size();
        while(l < r){
            int mid = l + (r - l) / 2;
            if(nums[mid] > target){
                r = mid;
            }else{
                l = mid + 1;
            }
        }
        return r - 1;
    }
    vector<int> searchRange(vector<int>& nums, int target) {
        if(nums.size() == 0) return {-1,-1};
        vector<int> ret(2,0);
        ret[0] = getLeft(nums,target);
        ret[1] = getRight(nums,target);
      //  cout<<ret[0]<<" "<<ret[1]<<endl;
        if(ret[1] < 0 || ret[0] >= nums.size() || nums[ret[0]] != target) return {-1,-1};
        
        return ret;
    }
};
